import waftools


def build(bld):
    sources = bld.path.ant_glob('**/*.c')

    def build_libutil(target, env):
        # Build the libbtutil directory using firmware environment
        bld.stlib(source=sources,
                  target=target,
                  includes=['.', 'include/btutil'],
                  use=['pblibc_includes', 'libutil_includes', 'root_includes'],
                  env=env.derive())

    bld(export_includes=['include'], name='libbtutil_includes')

    if (bld.variant != 'test'):
        build_libutil('libbtutil-cm0', bld.all_envs['cortex-m0'])

    build_libutil('libbtutil', bld.env)


# vim:filetype=python
